package day09API.stream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo01 {
    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        long time = System.currentTimeMillis();
        try {
            fis = new FileInputStream("TiMo.jpeg");
            fos = new FileOutputStream("./File/TiMo1.jpeg");
            int temp = 0;
            byte[] bytes = new byte[1024];
            int n;
            while ((n = fis.read(bytes))!=-1){
                fos.write(bytes,0,n);
            }

            long time1 = System.currentTimeMillis();
            System.out.println(time1-time);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
